function Project($scope, $http, $location) {
	var url = 'http://localhost:8080/openitems/rest/project';
	
    $scope.fetch = function(projectId){
    	
    	if(projectId != null){
    		url+='/'+projectId;
    	}
    	
    	 $http.get(url).
         success(function(data) {
        	 if(projectId == null){
        		 $scope.projectList = data;
        	 }else{
        		 $scope.project = data[0];
        	 }
             
         });    	
    };
    
    $scope.update = function(project) {
    	$http.post(url,project).success(function(response)
    			  {
    	    $scope.response = response;
    	    $scope.loading = false;
    	    $scope.fetch();
    	  });
      };
      
      $scope.editProject = function(project) {
    	    if (project === 'new') {
    	      $scope.newProject = true;
    	      $scope.project = null;
    	    }
    	    else {
    	      $scope.newProject = false;
    	      $scope.project = project;
    	      
    	    }
    };
    
    var projectId = $location.search()['pro']
    $scope.fetch(projectId);
}

